/*
 * @desc: 定义请求的错误类型
 * @Author: zhangshaohui
 * @Date: 2021-07-27 11:06:44
 * @Last Modified by: zhangshaohui
 * @Last Modified time: 2021-07-27 11:07:04
 */


import type { BizResponse } from './types';

/**
 * HTTP Error
 * HTTP 错误
 * @param {*} message     Error 必备属性
 * @param {*} statusCode  返回的 HTTP 状态码
 */
export class HttpError extends Error {
  statusCode: number;
  constructor(message: string, statusCode: number) {
    super(message);
    this.name = 'HttpError';
    this.message = message;
    this.statusCode = statusCode;
  }
}
/**
 * Interface Error
 * 接口错误
 * @param {*} message Error 必备属性
 * @param {*} response 返回接口数据
 */
export class InterfaceError extends Error {
  response: BizResponse<object>;
  constructor(message: string, response: BizResponse<object>) {
    super(message);
    this.name = 'InterfaceError';
    this.message = message;
    this.response = response;
  }
}
